<template>
	<view style="margin: 20px;">
		<button @click="GetWeather()">获取天气</button>
		<view class="" style="margin-left: 10%;">
			<text>天气详情{{hightTemp}}{{lowTemp}}</text>
		
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hightTemp: '',
				lowTemp: ''
			}
		},
		methods: {
			GetWeather() {
				uni.request({
					url: 'http://t.weather.sojson.com/api/weather/city/101230501',
					success: (res) => {
						const forecast12 = res.data.data.forecast.find(item => item.date === '12');
						if (forecast12) {
							console.log('12号最高气温是：', forecast12.high, '最低气温是', forecast12.low, forecast12.fx);
							this.hightTemp = forecast12.high;
							this.lowTemp = forecast12.low;
						} else {
							console.log('未找到12号天气数据');
						}
					}
				})
			}
		}
	}
</script>

<style>

</style>